class ProfileController < ApplicationController
  before_filter :login_required
  before_filter :load_user
  
  def update
    if @user.update_attributes(@user.filter_attributes(params[:user]))
      flash[:notice] = :profile_saved.l
      redirect_to :action => 'show'
    else
      render :action => 'edit'
    end
  end
  
  def change_password
    if request.post?
      if @user.authenticated? params[:old_password]
        if @user.update_attributes params[:user]
          flash[:notice] = :password_changed.l
          return redirect_to profile_url
        end
      else
        flash[:notice] = :old_password_invalid.l
      end
    end
  end
  
  private
  def load_user
    @user = current_user
  end  
  
end
